package easy;

public class Solution_1752 {

    public boolean check(int[] nums) {
        int index = -1;
        boolean flag = false;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] < nums[i - 1]) {
                index = i;
                if (flag) {
                    return false;
                }
                flag = true;
            }
        }
        return index < 0 || nums[0] >= nums[nums.length - 1];
    }

    public static void main(String[] args) {
        Solution_1752 model = new Solution_1752();
        System.out.println(model.check(new int[]{3, 4, 5, 1, 2}));
        System.out.println(model.check(new int[]{2, 1, 3, 4}));
        System.out.println(model.check(new int[]{1, 2, 3}));
        System.out.println(model.check(new int[]{1, 1, 1}));
        System.out.println(model.check(new int[]{2, 1}));
    }
}
